<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    677. Map Sum Pairs
   </h1>
   <p>
    Implement a MapSum class with
    <code>
     insert
    </code>
    , and
    <code>
     sum
    </code>
    methods.
   </p>
   <p>
    For the method
    <code>
     insert
    </code>
    , you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to the new one.
   </p>
   <p>
    For the method
    <code>
     sum
    </code>
    , you'll be given a string representing the prefix, and you need to return the sum of all the pairs' value whose key starts with the prefix.
   </p>
   <p>
    <b>
     Example 1:
    </b>
    <br>
   </p>
   <pre>
Input: insert("apple", 3), Output: Null
Input: sum("ap"), Output: 3
Input: insert("app", 2), Output: Null
Input: sum("ap"), Output: 5
</pre>
  </div>
  <div>
   <h1 class="question_title">
    677. 键值映射
   </h1>
   <p>
    实现一个 MapSum 类里的两个方法，
    <code>
     insert
    </code>
    &nbsp;和&nbsp;
    <code>
     sum
    </code>
    。
   </p>
   <p>
    对于方法&nbsp;
    <code>
     insert
    </code>
    ，你将得到一对（字符串，整数）的键值对。字符串表示键，整数表示值。如果键已经存在，那么原来的键值对将被替代成新的键值对。
   </p>
   <p>
    对于方法
    <code>
     sum
    </code>
    ，你将得到一个表示前缀的字符串，你需要返回所有以该前缀开头的键的值的总和。
   </p>
   <p>
    <strong>
     示例 1:
    </strong>
   </p>
   <pre>输入: insert("apple", 3), 输出: Null
输入: sum("ap"), 输出: 3
输入: insert("app", 2), 输出: Null
输入: sum("ap"), 输出: 5
</pre>
  </div>
 </body>
</html>